// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.advancedanimation;

import zombie.util.StringUtils;

public final class AnimationVariableSlotCallbackBool extends AnimationVariableSlotCallback<Boolean> {
    private boolean m_defaultValue = false;

    public AnimationVariableSlotCallbackBool(String key, AnimationVariableSlotCallbackBool.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
    }

    public AnimationVariableSlotCallbackBool(
        String key, AnimationVariableSlotCallbackBool.CallbackGetStrongTyped callbackGet, AnimationVariableSlotCallbackBool.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
    }

    public AnimationVariableSlotCallbackBool(String key, boolean defaultVal, AnimationVariableSlotCallbackBool.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
        this.m_defaultValue = defaultVal;
    }

    public AnimationVariableSlotCallbackBool(
        String key,
        boolean defaultVal,
        AnimationVariableSlotCallbackBool.CallbackGetStrongTyped callbackGet,
        AnimationVariableSlotCallbackBool.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
        this.m_defaultValue = defaultVal;
    }

    public Boolean getDefaultValue() {
        return this.m_defaultValue;
    }

    @Override
    public String getValueString() {
        return this.getValue() ? "true" : "false";
    }

    @Override
    public float getValueFloat() {
        return this.getValue() ? 1.0F : 0.0F;
    }

    @Override
    public boolean getValueBool() {
        return this.getValue();
    }

    @Override
    public void setValue(String val) {
        this.trySetValue(Boolean.valueOf(StringUtils.tryParseBoolean(val)));
    }

    @Override
    public void setValue(float val) {
        this.trySetValue(Boolean.valueOf((double)val != 0.0));
    }

    @Override
    public void setValue(boolean val) {
        this.trySetValue(Boolean.valueOf(val));
    }

    @Override
    public AnimationVariableType getType() {
        return AnimationVariableType.Boolean;
    }

    @Override
    public boolean canConvertFrom(String val) {
        return StringUtils.tryParseBoolean(val);
    }

    public interface CallbackGetStrongTyped extends AnimationVariableSlotCallback.CallbackGet<Boolean> {
    }

    public interface CallbackSetStrongTyped extends AnimationVariableSlotCallback.CallbackSet<Boolean> {
    }
}
